#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)
#define int long long
using pii=pair<int,int>;
#define gch getchar_unlocked
const int N=1e5+5,M=1e6+5;
const double eps=1e-10;
int n,m,L,V;
int d[N],v[N],a[N];
int c[M];
int ans1;
pii seg[N];
#define fi first
#define sc second
int st[N][18],lg[N],dp[N];
int query(int l,int r){
    int len=r-l+1;
    int lglen=lg[len];
    int len2=1<<lglen;
    return min(st[l][lglen],st[r-len2+1][lglen]);
}
bool chk(int l,int r){
    int ll=seg[r].fi,rr=query(l,r);
    if(ll>rr) return 0;
    return c[rr]-c[ll-1];
}
void exec(){ // T>1, need init!
    memset(c,0,sizeof c); memset(dp,0,sizeof dp); ans1=0;
    cin>>n>>m>>L>>V;
    rep(i,1,n)
        cin>>d[i]>>v[i]>>a[i];
    rep(i,1,m){
        int x; cin>>x;
        c[x]++;
    }
    rep(i,1,1000000) c[i]+=c[i-1];
    rep(i,1,n){
        if(v[i]>V && a[i]<0){
            double s=(1.0*V*V-1.0*v[i]*v[i]) / (2.0*a[i]);
            int l=d[i],r=min((int)(d[i]+s-eps),L);
            if(l>r) continue;
            if(c[r]-c[l-1]<=0) continue;
            seg[++ans1].fi=l; seg[ans1].sc=r;
        }
        else if(v[i]==V && a[i]>0){
            int l=d[i]+1,r=L;
            if(c[r]-c[l-1]<=0) continue;
            seg[++ans1].fi=l; seg[ans1].sc=r;
        }
        else if(v[i]>V && a[i]>=0){
            int l=d[i],r=L;
            if(c[r]-c[l-1]<=0) continue;
            seg[++ans1].fi=l; seg[ans1].sc=r;
        }
        else if(v[i]<V && a[i]>0){
            double s=(1.0*V*V-1.0*v[i]*v[i]) / (2.0*a[i]);
            int l=ceil(d[i]+s+eps),r=L;
            if(l>r) continue;
            if(c[r]-c[l-1]<=0) continue;
            seg[++ans1].fi=l; seg[ans1].sc=r;
        }
    }
    cout<<ans1<<" ";
    //huh ... pretty exhausted now.
    sort(seg+1,seg+ans1+1);
    memset(st,0x3f,sizeof st);
    rep(i,1,ans1) st[i][0]=seg[i].sc;
    rep(i,1,17){
        for(int j=1;j+(1<<i)-1<=ans1;j++){
            st[j][i]=min(st[j][i-1],st[j+(1<<(i-1))][i-1]);
        } 
    }
    rep(i,1,ans1){
        int l=0,r=i-1,ans;
        while(l<=r){
            int mid=(l+r)/2;
            if(chk(mid+1,i)) ans=mid,r=mid-1;
            else l=mid+1;
        }
        dp[i]=dp[ans]+1;
    }
    cout<<m-dp[ans1]<<endl;
}
signed main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    ios::sync_with_stdio(0);
    cin.tie(0);
    lg[1]=0;
    rep(i,2,100000) lg[i]=lg[i/2]+1;
    int t; cin>>t;
    while(t--) exec();
}